package com.ymatou.iapi.imbroadcast.testcase;

import org.json.JSONObject;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.imbroadcast.parameter.SendBroadcastBean;
import com.ymatou.iapi.imbroadcast.service.SendBroadcastCall;
import com.ymatou.iapi.orderdelivery.parameter.SubscribeExpressInfoBean;
import com.ymatou.iapi.orderdelivery.service.SubscribeExpressInfoCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymttest.utils.YMTDateUtil;


@TestSuite
public class Ts_SendBroadcast {
	
	public static SendBroadcastCall sendcall;
    public static SendBroadcastBean sendbean;
    YMTDateUtil date = new YMTDateUtil();
    
    @BeforeClass
	public static void setUp() {
		Logger.createResultFile("物流订阅接口");
	}

	@Before
	public void caseUp() {
		sendcall = new SendBroadcastCall();
		sendbean = new SendBroadcastBean();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(sendcall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	
	@SuppressWarnings("static-access")
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_SendBroadcast_001(){
		try {
			Logger.start(true, "创建一条买家广播");
			sendbean.setappId("app.ymatou.com");
			sendbean.setshowBroadcastSystemType(1);
			sendbean.setmessage("创建买家广播测试");
			sendbean.setbeginTime(date.getDate());
			sendbean.setendTime(date.getDate());
			sendbean.setpushTitle("dwtest推送主题");
			sendcall.setData(sendbean);
			sendcall.callService();
			Logger.verifyEquals(200, new JSONObject(sendcall.getReturnData()).getInt("status"), "响应报文-返回码");
		}
		catch(Exception e ) {
			Logger.fail(e);
		}
		
		
		
	}
	
	@SuppressWarnings("static-access")
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_SendBroadcast_002(){
		try {
			Logger.start(true, "创建一条买手广播");
			sendbean.setappId("app.ymatou.com");
			sendbean.setshowBroadcastSystemType(2);
			sendbean.setmessage("创建买家广播测试");
			sendbean.setbeginTime(date.getDate());
			sendbean.setendTime(date.getDate());
			sendbean.setpushTitle("dwtest推送主题");
			sendcall.setData(sendbean);
			sendcall.callService();
			Logger.verifyEquals(200, new JSONObject(sendcall.getReturnData()).getInt("status"), "响应报文-返回码");
		}
		catch(Exception e ) {
			Logger.fail(e);
		}
		
		
		
	}
	
	@SuppressWarnings("static-access")
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_SendBroadcast_003(){
		try {
			Logger.start(true, "广播内容为空  创建广播失败");
			sendbean.setappId("app.ymatou.com");
			sendbean.setshowBroadcastSystemType(2);
			sendbean.setmessage(null);
			sendbean.setbeginTime(date.getDate());
			sendbean.setendTime(date.getDate());
			sendbean.setpushTitle("dwtest推送主题");
			sendcall.setData(sendbean);
			sendcall.callService();
			Logger.verifyEquals(500, new JSONObject(sendcall.getReturnData()).getInt("status"), "响应报文-返回码");
		}
		catch(Exception e ) {
			Logger.fail(e);
		}
		
		
		
	}
}
